package com.itboye.mengwu.app.adapter;

import java.util.ArrayList;

import com.itboye.mengwu.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class Item2Adapter extends BaseAdapter {

	ArrayList<String> strs = new ArrayList<String>();
	Context context;

	public Item2Adapter(Context context, ArrayList<String> strs) {
		super();
		this.strs = strs;
		this.context = context;

	}

	@Override
	public int getCount() {

		return (strs != null & strs.size() > 0 ? strs.size() : 0);
	}

	@Override
	public Object getItem(int position) {

		return (strs != null & strs.size() > 0 ? strs.get(position) : null);
	}

	@Override
	public long getItemId(int position) {

		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder holder;
		LayoutInflater layoutInflater = LayoutInflater.from(context);
		if (convertView == null) {
			holder = new ViewHolder();

			convertView = layoutInflater.inflate(R.layout.item_fenlei_textview, null);
			holder.title = (TextView) convertView.findViewById(R.id.text);
			holder.lineLayout = (RelativeLayout) convertView.findViewById(R.id.lineLayout);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		holder.title.setText(strs.get(position));
		holder.lineLayout.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {

			}
		});

		return convertView;

	}

	class ViewHolder {
		public TextView title;
		public RelativeLayout lineLayout;

	}

}